package com.common.entity;

import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 * 定义返回结果
 */
@Component
public class MyResponse extends HashMap<String,Object> {
    public static final int SUCCESS = 200;
    public static final int FAIL = 0;
    private int code;
    private String message;
    private String result;

    public MyResponse success(){
        this.put("code",SUCCESS);
        return this;
    }
    public MyResponse fail(){
        this.put("code",FAIL);
        return this;
    }
    public MyResponse code(int code){
        this.put("code",code);
        return this;
    }

    public MyResponse message(String message){
        this.put("message",message);
        return this;
    }

    public MyResponse data(Object data){
        this.put("data",data);
        return this;
    }

}
